473,416 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Encode a URL to fit into a querystring

Hi Gang,

I need to know the javascript syntax to encode a URL to fit into a
querystring. Basically I want to pass the URL of the current web page
as the subject of an e-mail so it'd be something like:

var email_link = "<a href=\"mailto:wh*****@wherever.com?subject=" +
document.URL + "\">";
document.write(email_link);

Thanks so much,
Christian Blackburn

Jun 13 '06 #1
3 6233
Christian Blackburn wrote:
I need to know the javascript syntax to encode a URL to fit into a
querystring.


var o1 = '?&%=';
var o2 = escape(o1);
alert(o2);

--
Bart

Jun 13 '06 #2

Christian Blackburn wrote:
Hi Gang,

I need to know the javascript syntax to encode a URL to fit into a
querystring. Basically I want to pass the URL of the current web page
as the subject of an e-mail so it'd be something like:

var email_link = "<a href=\"mailto:wh*****@wherever.com?subject=" +
document.URL + "\">";
document.write(email_link);

Thanks so much,
Christian Blackburn


I use http://javascript-library.blogdrive.com/archive/17.html

function esc(s){return
window.encodeURIComponent?encodeURIComponent(s):es cape(s)}
var email_link = "<a href=\"mailto:wh*****@wherever.com?subject=" +
esc(document.URL) + "\">";
document.write(email_link);

Jun 13 '06 #3
Hi Guys,

Thank you both for your help. The escape() command worked perfectly.

Cheers,
Christian

Jun 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Arpan | last post by:
A link has the following URL: <a href="Page1.asp?cname=<%= Request.QueryString("cname") %>&cadd1=<%= Request.QueryString("cadd1") %>&cadd2=<%= Request.QueryString("cadd2") %>&cplace=<%=...
13
by: darrel | last post by:
I am creating a querystring to look like this: form_edit.aspx?collectionID=25&amp;confirmationMessage=New+form+entry+saved Note that I'm escaping the ampersand. However, I can't grab the...
1
by: apiringmvp | last post by:
I am trying to post a large amount of data from an XmlSerialized Arraylist that is converted into a string of hex values. When I pass it to a querystring sometimes its gets truncated. Is there...
2
by: Ryan | last post by:
Hi. I am trying to encrypt some data being passed between two aspx pages using querystring. I have tried bith DES and Rijndael and have run across the following problem. After either provider...
2
by: Larry | last post by:
I am hoping there is a way to encode the querystring part of a URL reached from a hyperlink that will cause the Request to not drop the info after the # in the URL string. Any clues or links to...
6
by: Mehdi | last post by:
Hi, I get the following URL on page load: http://www.server1.com?RedirectUrl=http://www.server2.com?id=777 So QueryString will return (after cleaning up via URL Encode/decode) :...
3
by: Dariusz Tomon | last post by:
Hi My problem is like that: I'm trying to pass values branza and jezyk in querysting: http://localhost/euroadres/pokazbranza.aspx?branza=transport lotniczy&jezyk=1 Branza is type...
4
by: | last post by:
Hi all, If I am reading this right, then the querystring parameters must be "&amp;" and not "&". However, IIS 6.0 and asp.net request.querystring fails to capture the values if "&amp;" is specified....
3
by: Elroyskimms | last post by:
I have to encode an address which contains an ampersand (&) into a URL with various querystring parameters. The following code works fine: URLString = "www.myserver.com?AD1=" &...
2
by: subbusuresh | last post by:
hi, Any one can help me. <asp:GridView ID="grvDCList" runat="server" AutoGenerateColumns="False" > <Columns> <asp:HyperLinkField HeaderText="DC Number" DataNavigateUrlFields="Code" ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.